package com.dotflat.fin.service.impl;

import com.dotflat.fin.domain.FinPayConfig;
import com.dotflat.fin.repository.FinPayConfigRepository;
import com.dotflat.fin.service.FinPayConfigService;
import com.dotflat.rest.PO.AreableObjectBasePO;
import com.dotflat.rest.service.impl.AreableObjectBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单信息service
 *
 * @author ：Ron
 * @date ：Created in 2020/10/30 13:06
 */
@Service
public class FinPayConfigServiceImpl extends AreableObjectBaseServiceImpl<FinPayConfig, FinPayConfigRepository> implements FinPayConfigService {

    @Override
    @Autowired
    public void setBaseRepository(FinPayConfigRepository baseRepository) {
        super.setBaseRepository(baseRepository);
    }

    @Override
    public FinPayConfig add(String areaId, String staffId, AreableObjectBasePO param) {

        //确保园所总是只有一个对象
        FinPayConfig current = baseRepository.findFirstByAreaId(areaId);
        if (current != null){
            param.setId(current.getId());
        }

        return add(areaId, staffId, param, null);
    }

}
